<?php 
    session_start();
    
    if(!isset($_SESSION['myusername'])){
        header("location:index.php");
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Brops Dox</title>
        <link href="styles/styles.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="script/ajax.js"></script>

    </head>

    <body>
        <div id="mainWrap">
            <div id="mainPanel">
                <div id="menu">
                    <ul>
                        <li><a href="#"><span>Hello, <?php echo $_SESSION['myusername']; ?></span></a></li>
                        <li><div class="blank"></div></li>
                        <li><a href="dashboard.php"><span>Dashboard</span></a></li>
                        <li><div class="blank"></div></li>
                        <li><a href="signout.php"><span>Sign Out</span></a></li>
                    </ul>
                </div>
                <div id="logoWrap"><a href="dashboard.php"><h1>Brops Dox</h1></a></div>
                <!--<h2><a href="dashboard.html">Dashboard</a></h2>-->
                <div id="leftPanel">
                    <div class="about">
                        <h2>Dashboard</h2>
                        <h3>Your Folders</h3>

                        <div id="atas">
                            <input name="fileupload" type="file" />
                            <button>upload</button>
                        </div>
                        </br>
                        <div id="bawah">
                            <table id="dir">
                                <tr>
                                    <th>File Name</th>
                                    <th>File Type</th>
                                    <th>File Size</th>
                                    <th>Date Modified</th>
                                    <th>Action</th>
                                </tr>
                                
                                <?php 
                                $path = "./path/".$_SESSION['myusername'];
                                if(is_dir($path)){
                                    $dh = opendir($path);
                                    while(($file = readdir($dh))!== false)
                                    {
                                        if ($file != "." && $file != "..") {
                                            echo "<tr class='alt'>";
                                            if (is_dir($path.'\\'.$file)){
                                                echo "<td><a href='getlist.php?dir="."$path"."/"."$file"."'>"."$file"."</a></td>";
                                            } else {
                                                echo "<td>"."$file\n"."</td>";
                                            }
                                            echo "<td>".filetype($path.'\\'.$file)."</td>";
                                            echo "<td>".filesize($path.'\\'.$file)." bytes</td>";
                                            echo "<td>".date ("F d Y H:i:s.", filemtime($path.'\\'.$file))."</td>";
                                            //echo "<td>Download</td>";
                                            if (!is_dir($path.'\\'.$file)){
                                                echo "<td><a href='download.php?file="."$file"."'>Download</a></td>";
                                            } else {
                                                echo "<td></td>";
                                            }
                                            //echo "filename : " . $file . " filetype : " . filetype($path.'\\'.$file)."</br>";
                                        }
                                    }
                                    closedir($dh);
                                }
                                    
                                ?>
                                    </tr>
                            </table>
                            
                            <?php
            include "connector.php";

            $sql = "SELECT * FROM user";
            $result = mysql_query($sql, $con);

            while ($row = mysql_fetch_array($result)) {
                //echo $row['username'];
                //echo "</br>";
                //echo $row['password'];
                //echo "</br>";
                //echo $row['email'];
                //echo "</br>";
            }
            ?>
                        </div>

                    </div>
                </div>
    </body>
</html>
